import http from "../utils/request";

import { RegisterUser } from "../pages/register";
import { UpdatePass } from "../pages/update-password";
import { UpdateInfo, UserInfo } from "../pages/update-info";

export const login: (username: string, password: string)=>Promise<any> = (username: string, password: string)=>{
    return http.post("/user/login", {
        username, password
    })
}

export const register:(registerUser: RegisterUser)=>Promise<any> = (registerUser: RegisterUser) =>{
    return http.post("/user/register", registerUser);
}

export const getCaptcha:(address: string)=>Promise<any> = (address)=>{
    return http.get("/user/register-captcha", { params: {address} });
}

export const forgetPassword:(data: UpdatePass )=>Promise<any> = (data)=>{
    return http.post("/user/update_password", data);
}

export const forgetPasswordCaptcha:(address: string)=>Promise<any> = (address)=>{
    return http.get("/user/update_password/captcha", { params: {address} });
}

export const getUserInfo = ()=>{
    return http.get("/user/info");
}

export const alterInfo = (data: UserInfo)=>{
    return http.post("/user/update", data);
}

export const updateUserInfoCaptcha = ()=>{
    return http.get("/user/update/captcha");
}